![]() |
ALMaSS
1.0
The Animal, Landscape and Man Simulation System
|
The base class for hunters encompsassing all their general behaviours. More...
#include <Hunters_all.h>
Public Member Functions | |
Hunter (struct_Hunter *p_data, Hunter_Population_Manager *p_PPM) | |
The constructor for the Hunter class. More... | |
virtual | ~Hunter () |
The destructor for the Hunter class. More... | |
int | GetHuntingDays () |
Gets the annual hunting attempts count. More... | |
int | GetBag () |
Gets the annual hunting bag. More... | |
int | GetShots () |
Gets the number of shots this season to-date. More... | |
virtual void | ResetBag () |
Sets the annual hunting bag to zero. More... | |
void | ResetHuntingOpportunities () |
Sets the annual hunting attempts count to zero. More... | |
int | GetClock () |
Supplies the clock time. More... | |
void | ResetClock () |
Sets the clock back to zero. More... | |
void | ResetSeasonData () |
Sets the bag and hunting counters to zero. More... | |
bool | IsOutHunting () |
A debug function, but may be useful in other contexts. Returns true of currently out hunting. More... | |
void | OnMorning () |
Optimism in the morning, perhaps we should hunt? More... | |
int | GetRef () |
Provide our ref name. More... | |
APoint | GetHome () |
Provide our home coords. More... | |
int | GetHuntField () |
Get the polygon reference number to our current hunting field (which is at a hunting location) More... | |
APoint | GetHuntLoc (unsigned a_ref) |
Provide our hunting location coords. More... | |
Farm * | GetFarmerRef (unsigned a_ref) |
Provide our ref name. More... | |
virtual bool | InSeason (int) |
Is it hunting season? - MUST be overridden in descendent class. More... | |
virtual bool | IsSeasonEnd (int) |
Is it the end of the hunting season? - MUST be overridden in descendent class. More... | |
virtual int | GetSeasonLengthLeft (int) |
Returns the length of the hunting season in days - MUST be overridden in descendent class. More... | |
virtual void | SaveMyData (ofstream *) |
Each hunter needs to save different kinds of data, so we use a polymorphic method for this. More... | |
virtual void | OnShoot () |
On shoot message handler - must be overidden in descendent classes. More... | |
virtual void | OnGoHome () |
On gohome message handler - must be overidden in descendent classes. More... | |
![]() | |
unsigned | SupplyFarmOwnerRef () |
AnimalPosition | SupplyPosition () |
APoint | SupplyPoint () |
int | SupplyPolygonRef () |
int | Supply_m_Location_x () |
int | Supply_m_Location_y () |
virtual void | KillThis () |
virtual void | CopyMyself () |
void | SetX (int a_x) |
void | SetY (int a_y) |
TAnimal (int x, int y, Landscape *L) | |
virtual void | BeginStep (void) |
BeingStep behaviour - must be implemented in descendent classes. More... | |
virtual void | Step (void) |
Step behaviour - must be implemented in descendent classes. More... | |
virtual void | EndStep (void) |
EndStep behaviour - must be implemented in descendent classes. More... | |
virtual void | ReinitialiseObject (int x, int y, Landscape *L) |
Used to re-use an object - must be implemented in descendent classes. More... | |
virtual int | WhatState () |
virtual void | Dying () |
void | CheckManagement (void) |
void | CheckManagementXY (int x, int y) |
virtual bool | OnFarmEvent (FarmToDo) |
![]() | |
int | GetCurrentStateNo () |
Returns the current state number. More... | |
void | SetCurrentStateNo (int a_num) |
Sets the current state number. More... | |
bool | GetStepDone () |
Returns the step done indicator flag. More... | |
void | SetStepDone (bool a_bool) |
Sets the step done indicator flag. More... | |
virtual void | ReinitialiseObject () |
Used to re-use an object - must be implemented in descendent classes. More... | |
TALMaSSObject () | |
The constructor for TALMaSSObject. More... | |
virtual | ~TALMaSSObject () |
The destructor for TALMaSSObject. More... | |
void | OnArrayBoundsError () |
Used for debugging only, tests basic object properties. More... | |
Protected Member Functions | |
virtual TypeOfHunterState | st_ShouldGoHunting (void) |
Decide whether to go out hunting on a specific day. More... | |
TypeOfHunterState | st_OutHunting (void) |
The basic hunting behaviour. More... | |
TypeOfHunterState | st_Resting (void) |
Finished hunting and waiting for the next opportunity. More... | |
virtual void | Init (struct_Hunter *p_data) |
Initiation of a basic hunter here. More... | |
bool | IsTodayAPreferredHuntDay (int a_today) |
Checks for the hunting day preference (weekday or any day) More... | |
bool | IsTodayAChosenHuntDay (int a_today) |
Uses a probability test to determine whether to go hunting today. More... | |
virtual int | CheckForGame (void) |
If the hunter checks for game at their hunting locations then this is done here. Must be overridden. More... | |
![]() | |
void | CorrectWrapRound () |
Corrects wrap around co-ordinate problems. More... | |
Protected Attributes | |
int | m_myname |
A reference number unique to this hunter. More... | |
TypeOfHunterState | m_CurrentHState |
The current hunter behavioural state. More... | |
Hunter_Population_Manager * | m_OurPopulationManager |
Pointer to the population manager. More... | |
int | m_clock |
Records the time spent hunting per day. More... | |
int | m_bag |
The numbers of game items shot todate this year. More... | |
int | m_myShots |
The numbers of shots to-date this year. More... | |
int | m_myMagazine |
The number of shells in the magazine. More... | |
int | m_huntingdays |
The numbers of days used for hunting this year. More... | |
int | m_lasthuntday |
The date for the last hunt day. More... | |
int | m_baglimit |
Annual self-imposed limit on number shot - unused at present. More... | |
int | m_huntlimit |
Annual self-imposed limit on number of days spent hunting. More... | |
double | m_efficiency |
Probability of 'hitting' a game item. More... | |
double | m_goosecountchance |
Probability of checking for geese in hunting area. More... | |
int | m_weekend |
Code for weekly hunting activity. More... | |
vector< Farm * > | m_OurFarmers |
List of pointers to the farmers whose land the hunter hunts More... | |
APoint | m_Home |
int | m_huntfield_polyref |
The polygon reference number to our current hunting field (which is at a hunting location) More... | |
int | m_NoHuntLocs |
vector< int > | m_HuntLocRefs |
vector< APoint > | m_HuntLocs |
![]() | |
int | m_Location_x |
int | m_Location_y |
Landscape * | m_OurLandscape |
![]() | |
int | m_CurrentStateNo |
The basic state number for all objects - '-1' indicates death. More... | |
bool | m_StepDone |
Indicates whether the iterative step code is done for this timestep. More... | |
The base class for hunters encompsassing all their general behaviours.
The hunter class specifies general hunter behaviours that are common to all hunter types.
Hunter::Hunter | ( | struct_Hunter * | p_data, |
Hunter_Population_Manager * | p_PPM | ||
) |
The constructor for the Hunter class.
References Init(), and m_OurPopulationManager.
|
virtual |
The destructor for the Hunter class.
|
inlineprotectedvirtual |
If the hunter checks for game at their hunting locations then this is done here. Must be overridden.
Reimplemented in GooseHunter.
|
inline |
|
inline |
|
inline |
Provide our ref name.
References m_OurFarmers.
|
inline |
Get the polygon reference number to our current hunting field (which is at a hunting location)
References m_huntfield_polyref.
Referenced by Hunter_Population_Manager::DoFirst().
|
inline |
Gets the annual hunting attempts count.
References m_huntingdays.
Referenced by GooseHunter::SaveMyData().
|
inline |
|
inline |
|
inlinevirtual |
Returns the length of the hunting season in days - MUST be overridden in descendent class.
Reimplemented in GooseHunter.
Referenced by IsTodayAChosenHuntDay().
|
inline |
Gets the number of shots this season to-date.
References m_myShots.
Referenced by GooseHunter::SaveMyData().
|
protectedvirtual |
Initiation of a basic hunter here.
References cfg_hunter_magazinecapacity, m_bag, m_baglimit, m_clock, m_CurrentHState, struct_Hunter::m_efficiency, m_efficiency, struct_Hunter::m_farms, struct_Hunter::m_goosecountchance, m_goosecountchance, struct_Hunter::m_home, m_Home, m_huntingdays, struct_Hunter::m_huntingdayslimit, m_huntlimit, struct_Hunter::m_huntlocrefs, m_HuntLocRefs, struct_Hunter::m_huntlocs, m_HuntLocs, m_lasthuntday, m_myMagazine, m_myname, m_myShots, m_NoHuntLocs, m_OurFarmers, struct_Hunter::m_ref, struct_Hunter::m_weekend, m_weekend, tohts_InitialState, and CfgInt::value().
Referenced by Hunter().
|
inlinevirtual |
Is it hunting season? - MUST be overridden in descendent class.
Reimplemented in GooseHunter.
Referenced by st_ShouldGoHunting().
|
inline |
A debug function, but may be useful in other contexts. Returns true of currently out hunting.
References m_CurrentHState, and tohts_OutHunting.
Referenced by Hunter_Population_Manager::DoFirst().
|
inlinevirtual |
Is it the end of the hunting season? - MUST be overridden in descendent class.
Reimplemented in GooseHunter.
Referenced by Hunter_Population_Manager::DoFirst().
|
inlineprotected |
Uses a probability test to determine whether to go hunting today.
[in] | a_today | The day in the year |
Calculates the season length left, then divides the number of hunting days still needed by this to get a probability of going each day. This probability is scaled to hedge our bets for going earlier in the season. Then a probability test is taken and the value returned as true = go today, or false = don't go To calculate this we need the remaining season length. Then if a weekend hunter this is multiplied by 2/7 to get weekends. We assume that we will hedge our bets to some extent, so the probability is based on scaler*daysneeded/dayspossible e.g. if scaler is 2 and we need 2 days and 10 are left, the chance of going is 2*2/10 per day = 40%.
References cfg_hunterhuntdayprobscaler, g_rand_uni, GetSeasonLengthLeft(), m_huntingdays, m_huntlimit, m_weekend, and CfgFloat::value().
Referenced by st_ShouldGoHunting().
|
inlineprotected |
Checks for the hunting day preference (weekday or any day)
[in] | a_today | The day in the year |
Checks whether today is a weekend, if so and weekend hunter then hunt chance today, if not no chance. Otherwise if not a weekend hunter all is good to hunt.
References cfg_hunterrefractionperiod, m_lasthuntday, TAnimal::m_OurLandscape, m_weekend, Landscape::SupplyGlobalDate(), and CfgInt::value().
Referenced by st_ShouldGoHunting().
|
inlinevirtual |
On gohome message handler - must be overidden in descendent classes.
Reimplemented in GooseHunter.
|
inline |
Optimism in the morning, perhaps we should hunt?
References m_CurrentHState, and tohts_Hunting.
Referenced by Hunter_Population_Manager::DoFirst().
|
inlinevirtual |
On shoot message handler - must be overidden in descendent classes.
Reimplemented in GooseHunter.
|
inlinevirtual |
Sets the annual hunting bag to zero.
Reimplemented in GooseHunter.
References m_bag, and m_myShots.
Referenced by GooseHunter::ResetBag(), and ResetSeasonData().
|
inline |
Sets the clock back to zero.
References m_clock.
Referenced by Hunter_Population_Manager::DoFirst(), and GooseHunter::Init().
|
inline |
Sets the annual hunting attempts count to zero.
References m_huntingdays.
Referenced by ResetSeasonData().
|
inline |
Sets the bag and hunting counters to zero.
References ResetBag(), and ResetHuntingOpportunities().
Referenced by Hunter_Population_Manager::DoFirst(), and GooseHunter::Init().
|
inlinevirtual |
Each hunter needs to save different kinds of data, so we use a polymorphic method for this.
Reimplemented in GooseHunter.
Referenced by Hunter_Population_Manager::DoFirst().
|
protected |
The basic hunting behaviour.
Must not be called, has to be overridden in descendent classes.
References tohts_foobar.
|
protected |
Finished hunting and waiting for the next opportunity.
Just stays doing this until called out again by the population manager
References tohts_Resting.
Referenced by GooseHunter::Step().
|
protectedvirtual |
Decide whether to go out hunting on a specific day.
This is called at the beginning of each day, if it is decided to go hunting then this is done for each 10 minute period. First check we have not shot our limit this year or done our allocated number of days, if so do nothing.
Otherwise we want to find out if we should hunt today - this depends on the season for our game species, and whether we want to hunt today - which depends on whether it is a weekend or not - and then how eager we are.
We've established that it is legal to hunt today but whether the hunter goes depends on how eager he is. This is determined by a probability that is based on the number of days needed to fulfil the hunting day limit, and the number of possible days left in the season. This will also depend on whether they are a weekend hunter or not, and finally whether he checks if there are geese on his hunting locations (done in st_OutHunting ).
When all the days are used up, the hunter will no longer enter this decision process.
Reimplemented in GooseHunter.
References InSeason(), IsTodayAChosenHuntDay(), IsTodayAPreferredHuntDay(), m_bag, m_baglimit, m_huntingdays, m_huntlimit, TAnimal::m_OurLandscape, Landscape::SupplyDayInYear(), tohts_OutHunting, and tohts_Resting.
Referenced by GooseHunter::st_ShouldGoHunting().
|
protected |
The numbers of game items shot todate this year.
Referenced by GetBag(), Init(), GooseHunter::OnShotABird(), ResetBag(), and st_ShouldGoHunting().
|
protected |
Annual self-imposed limit on number shot - unused at present.
Referenced by Init(), and st_ShouldGoHunting().
|
protected |
Records the time spent hunting per day.
Referenced by GetClock(), Init(), ResetClock(), and GooseHunter::st_OutHunting().
|
protected |
The current hunter behavioural state.
Referenced by Init(), IsOutHunting(), GooseHunter::OnGoHome(), OnMorning(), and GooseHunter::Step().
|
protected |
Probability of 'hitting' a game item.
Referenced by Init(), GooseHunter::OnShoot(), and GooseHunter::st_OutHunting().
|
protected |
Probability of checking for geese in hunting area.
Referenced by GooseHunter::CheckForGame(), and Init().
|
protected |
|
protected |
The polygon reference number to our current hunting field (which is at a hunting location)
Referenced by GetHuntField(), GooseHunter::OnGoHome(), GooseHunter::OnShoot(), and GooseHunter::st_OutHunting().
|
protected |
The numbers of days used for hunting this year.
Referenced by GetHuntingDays(), Init(), IsTodayAChosenHuntDay(), ResetHuntingOpportunities(), GooseHunter::st_OutHunting(), and st_ShouldGoHunting().
|
protected |
Annual self-imposed limit on number of days spent hunting.
Referenced by Init(), IsTodayAChosenHuntDay(), and st_ShouldGoHunting().
|
protected |
\ The hunting location ref numbers
Referenced by Init().
|
protected |
\ The hunting locations centroid of the farm held in m_OurFarmer
Referenced by GetHuntLoc(), and Init().
|
protected |
The date for the last hunt day.
Referenced by Init(), IsTodayAPreferredHuntDay(), and GooseHunter::st_OutHunting().
|
protected |
The number of shells in the magazine.
Referenced by Init(), and GooseHunter::st_OutHunting().
|
protected |
A reference number unique to this hunter.
Referenced by GetRef(), Init(), GooseHunter::OnShotABird(), and GooseHunter::SaveMyData().
|
protected |
The numbers of shots to-date this year.
Referenced by GetShots(), Init(), GooseHunter::OnShoot(), ResetBag(), and GooseHunter::st_OutHunting().
|
protected |
/brief The number of farms he can hunt on
Referenced by GooseHunter::Init(), and Init().
|
protected |
List of pointers to the farmers whose land the hunter hunts
Referenced by GetFarmerRef(), GooseHunter::GooseHunter(), GooseHunter::Init(), and Init().
|
protected |
Pointer to the population manager.
Referenced by GooseHunter::GetSeasonLengthLeft(), Hunter(), GooseHunter::InSeason(), GooseHunter::IsSeasonEnd(), GooseHunter::OnShotABird(), and GooseHunter::st_OutHunting().
|
protected |
Code for weekly hunting activity.
Referenced by Init(), IsTodayAChosenHuntDay(), and IsTodayAPreferredHuntDay().